﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SCMS
{
    public class Items
    {
        public ItemsInfo mItemsInfo;

        public Items()
        {
            mItemsInfo = new ItemsInfo();
        }

        public bool Save()
        {
            DAOManager l_dao = new DAOManager();
            bool l_result = false;
            l_dao.CreateConnection();
            ItemsDAO l_itemsDAO = new ItemsDAO(l_dao);

            l_itemsDAO.Info = mItemsInfo;
            l_dao.BeginTransaction();
            l_result = l_itemsDAO.Save();
            l_dao.CommitTransaction();
            return l_result;
        }

        public ItemsInfo Find()
        {
            DAOManager l_dao = new DAOManager();
            l_dao.CreateConnection();
            ItemsDAO l_ItemsDAO = new ItemsDAO(l_dao);
            l_ItemsDAO.Info = mItemsInfo;
            return l_ItemsDAO.Find();
        }

        public bool Delete()
        {
            DAOManager l_dao = new DAOManager();
            l_dao.CreateConnection();
            bool l_result = false;
            l_dao.BeginTransaction();
            ItemsDAO l_ItemsDAO = new ItemsDAO(l_dao);
            l_ItemsDAO.Info = mItemsInfo;
            l_result = l_ItemsDAO.Delete();
            l_dao.CommitTransaction();
            return l_result;
        }
    }
}
